package com.lz.yz.base.entity;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import java.io.Serializable;

@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
public class ReturnValue implements Serializable {
    private static final long serialVersionUID = -3217633508940695532L;

    public static final int STATUS_CODE_200 = 200;
    public static final int STATUS_CODE_500 = 500;
    private int code;
    private String message;
    private Object data;

    public ReturnValue(int code) {
        this.code = code;
    }

    public ReturnValue(int code, Object data) {
        this.code = code;
        this.data = data;
    }

    public static ReturnValue generateFalseReturnValue(Integer code,String error,Object data) {
        ReturnValue rv = new ReturnValue(code);
        rv.setMessage(error);
        rv.setData(data);
        return rv;
    }

    public static ReturnValue generateFalseReturnValue(String error,Integer code) {
        ReturnValue rv = new ReturnValue(code);
        rv.setMessage(error);
        return rv;
    }

    public static ReturnValue generateFalseReturnValue(String error) {
        ReturnValue rv = new ReturnValue(STATUS_CODE_500);
        rv.setMessage(error);
        return rv;
    }

    public static ReturnValue generateTrueReturnValue() {
        ReturnValue rv = new ReturnValue(STATUS_CODE_200);
        return rv;
    }

    public static ReturnValue generateTrueReturnValue(Object data) {
        ReturnValue rv = generateTrueReturnValue();
        rv.setData(data);
        return rv;
    }

    public static ReturnValue generateTrueMsgReturnValue(String message) {
        ReturnValue rv = generateTrueReturnValue();
        rv.setMessage(message);
        return rv;
    }
    public static ReturnValue generateTrueReturnValue(String message,Object data) {
        ReturnValue rv = generateTrueReturnValue();
        rv.setMessage(message);
        rv.setData(data);
        return rv;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }
}
